package nl.windgazer.arachne.services.messages;

import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.tapestry5.MarkupWriter;

/**
 * This is the service that provides for in-memory (temporary)translations of messages.
 * 
 * @author mreuring
 */
public interface MessageInterceptEventListener {
	/**
	 * Before pushing this service unto the environment the MarkupWriter must be provided.
	 * 
	 * @param writer
	 */
	public void setMarkupWriter(MarkupWriter writer);

	/**
	 * This method will provide intercepting methods with access to the translated content and
	 * also to notify that a message has been intercepted so that this service may attempt to
	 * add markup to the currently rendering element.
	 * 
	 * @param key
	 * @param msg
	 * @param locale
	 * @return
	 */
	public String intercept(String key, String msg, Locale locale);
	public String intercept(String key, String msg, String property, Locale locale, Object... arg1);

	/**
	 * Returns all intercepted messages. For use, for instance, of initialising the JavaScript tooling.
	 * @return
	 */
	public Map<String, InterceptedMessageVO> getIntercepted();
	
	/**
	 * Add a new translation to the in-memory storage
	 * @param key
	 * @param value
	 * @param pageName
	 * @param locale
	 */
	public void addMsg(String key, String value, String pageName, Locale locale);
	
	/**
	 * Get an overview of all current translations still in memory.
	 * @return
	 */
	public List<TranslatedMessageVO> getAllTranslatedMessages();

}
